package com.gexiaobao.pigeon.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.gexiaobao.pigeon.app.model.bean.AllReserveMemberInfoResponse
import com.gexiaobao.pigeon.app.model.bean.AllVisitInfoResponse
import com.gexiaobao.pigeon.app.model.bean.AnnouncementDetailResponse
import com.gexiaobao.pigeon.app.model.bean.AppTeamListResponse
import com.gexiaobao.pigeon.app.model.bean.DrippingBaseInfoResponse
import com.gexiaobao.pigeon.app.model.bean.FeatherColorResponse
import com.gexiaobao.pigeon.app.model.bean.GetVideoListResponse
import com.gexiaobao.pigeon.app.model.bean.LiveAnnouncementResponse
import com.gexiaobao.pigeon.app.model.bean.LoftMemberInfoResponse
import com.gexiaobao.pigeon.app.model.bean.LoftMemberResponse
import com.gexiaobao.pigeon.app.model.bean.MemberCodeResponse
import com.gexiaobao.pigeon.app.model.bean.MemberReservationResponse
import com.gexiaobao.pigeon.app.model.bean.MessageListResponse
import com.gexiaobao.pigeon.app.model.bean.OrgInfoDetailResponse
import com.gexiaobao.pigeon.app.model.bean.OrgInfoResponse
import com.gexiaobao.pigeon.app.model.bean.OrgMatchResponse
import com.gexiaobao.pigeon.app.model.bean.PigeonFosterBean
import com.gexiaobao.pigeon.app.model.bean.PlatFormIdResponse
import com.gexiaobao.pigeon.app.model.bean.RaceInfoResponse
import com.gexiaobao.pigeon.app.model.bean.ReceiptPigeonResponse
import com.gexiaobao.pigeon.app.model.bean.RegulationListBean
import com.gexiaobao.pigeon.app.model.bean.UiState
import com.gexiaobao.pigeon.app.model.bean.VisitMemberListResponse
import com.gexiaobao.pigeon.app.model.bean.VisitNoticeResponse
import com.gexiaobao.pigeon.app.model.bean.VisitReservationResponse
import com.gexiaobao.pigeon.app.model.bean.VisitSettingResponse
import com.gexiaobao.pigeon.app.model.param.AddDrippingParam
import com.gexiaobao.pigeon.app.model.param.AddMemberReservationParam
import com.gexiaobao.pigeon.app.model.param.FollowOrgParams
import com.gexiaobao.pigeon.app.model.param.VoucherParams
import com.gexiaobao.pigeon.app.network.ListDataUiState
import com.gexiaobao.pigeon.app.network.apiService
import com.gexiaobao.pigeon.app.util.RxToast
import com.gexiaobao.pigeon.app.util.SettingUtil
import kotlinx.coroutines.launch
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.callback.databind.BooleanObservableField
import me.hgj.jetpackmvvm.callback.databind.StringObservableField
import me.hgj.jetpackmvvm.ext.request
import me.hgj.jetpackmvvm.util.LogUtils
import okhttp3.RequestBody
import java.io.File

/**
 * created by : hxw
 * @date : 20221124
 * Describe :
 */
class OrgDetailViewModel : BaseViewModel() {

    private var pageNo: Int = 1
    private val pageSize: Int = 20

    val title = StringObservableField()
    val vipNum = StringObservableField()
    val careNum = StringObservableField()

    val desc = StringObservableField()

    //会员数量
    val memberNum = StringObservableField()

    //关注数量
    val followNum = StringObservableField()

    //加入状态
    val joinStatusStr = StringObservableField()

    //关注状态
    val followStatusStr = StringObservableField()

    //是否可修改（编辑）
    val isEdit = BooleanObservableField()

    //预定的起止时间
    val startAndEndTime = StringObservableField()


    /** 关注组织 */
    val followOrgResult: MutableLiveData<UiState> = MutableLiveData()

    /** 公告获取组织信息 */
    val orgInfoResult: MutableLiveData<OrgInfoResponse> = MutableLiveData()

    /** 获取最新直播公告（app端）  */
    val liveAnnouncementResult = MutableLiveData<LiveAnnouncementResponse>()
    fun getLatestLiveStreamingAnnouncement(raceId: Int, orgId: Int) {
        request(
            { apiService.getLatestLiveStreamingAnnouncement(raceId, orgId) }, {
                liveAnnouncementResult.value = it
            }, {
                RxToast.showToast(it.msg)
            }
        )
    }

    /** 获取规程详情  */
    val announcementDetailResult = MutableLiveData<AnnouncementDetailResponse>()
    fun getAnnouncementDetail(id: String) {
        request(
            { apiService.getAnnouncementDetail(id) }, {
                announcementDetailResult.value = it
            }, {
                RxToast.showToast(it.msg)
            }
        )
    }

    /** 获取规程公告列表（app端） */
    val regulationAnnouncementResult: MutableLiveData<ListDataUiState<RegulationListBean>> = MutableLiveData()
    fun getRegulationAnnouncementList(isRefresh: Boolean, orgId: Int) {
        if (isRefresh) {
            pageNo = 1
        }
        request(
            { apiService.getRegulationAnnouncementList(pageSize, pageNo, orgId) }, {
                pageNo++
                val listDataUiState = ListDataUiState(
                    isSuccess = true,
                    isRefresh = isRefresh,
                    isEmpty = it.isEmpty(),
                    isFirstEmpty = isRefresh && it.isEmpty(),
                    total = it.total,
                    hasMore = it.hasMore(),
                    listData = it.list
                )
                regulationAnnouncementResult.value = listDataUiState
            }, {
                val listDataUiState = ListDataUiState(
                    isSuccess = false,
                    isRefresh = isRefresh,
                    errMessage = it.msg,
                    listData = arrayListOf<RegulationListBean>()
                )
                regulationAnnouncementResult.value = listDataUiState
            }
        )
    }

    /** 创建或更新频道 */
    val createChannelResult = MutableLiveData<Any>()
    fun createChannel(body: RequestBody) {
        request(
            { apiService.channel(body) }, {
                createChannelResult.value = it
            }, {
                RxToast.showToast(it.msg)
            }
        )
    }

    /** 创建群聊通道和添加成员 */
    fun createChannelAndSubscriber(body1: RequestBody, body2: RequestBody) {
        viewModelScope.launch {
            try {
                val result1 = apiService.channel(body1)

                val result2 = apiService.addSubscriber(body2)
                createChannelResult.value = result2
            } catch (e: Exception) {
                LogUtils.warnInfo("MainViewModel", "Error occurred: ${e.localizedMessage}")
            }
        }
    }

    /** 获取平台id */
    val platformIDResult = MutableLiveData<PlatFormIdResponse>()
    fun getPlatFormId() {
        request(
            { apiService.getPlatFormId() }, {
                platformIDResult.value = it
            }, {
                RxToast.showToast(it.msg)
            }
        )
    }

    /**  获取棚号  */
    var memberNumResult: MutableLiveData<MemberCodeResponse> = MutableLiveData()
    fun getMemberNum(id: String) {
        request({ apiService.getMemberNum(id) }, {
            memberNumResult.value = it
        }, {
            RxToast.showToast(it.msg)
        })
    }

    fun followOrg(param: FollowOrgParams) {
        request({ apiService.followOrg(param) }, {
            val deleteState = UiState(isSuccess = true)
            followOrgResult.value = deleteState
        }, {
            val deleteState = UiState(isSuccess = false, errorMsg = it.msg)
            followOrgResult.value = deleteState
        })
    }


    /** 取消关注组织 */
    val cancelFollowOrgResult: MutableLiveData<UiState> = MutableLiveData()
    fun cancelFollowing(param: FollowOrgParams) {
        request({ apiService.cancelFollowing(param) }, {
            val deleteState = UiState(isSuccess = true)
            cancelFollowOrgResult.value = deleteState
        }, {
            val deleteState = UiState(isSuccess = false, errorMsg = it.msg)
            cancelFollowOrgResult.value = deleteState
        })
    }

    /** 获取组织下赛事 */
    val orgMatchResult: MutableLiveData<ListDataUiState<OrgMatchResponse.ListInfo>> = MutableLiveData()
    fun getOrgRaceListApp(isRefresh: Boolean, orgId: String) {
        if (isRefresh) {
            pageNo = 1
        }
        request({ apiService.getOrgRaceListApp(orgId, pageSize, pageNo) }, {
            pageNo++
            val listDataUiState = ListDataUiState(
                isSuccess = true,
                isRefresh = isRefresh,
                isEmpty = it.isEmpty(),
                isFirstEmpty = isRefresh && it.isEmpty(),
                total = it.total,
                hasMore = it.hasMore(),
                listData = it.data
            )
            orgMatchResult.value = listDataUiState
        }, {
            val listDataUiState = ListDataUiState(
                isSuccess = false, isRefresh = isRefresh, errMessage = it.msg, listData = arrayListOf<OrgMatchResponse.ListInfo>()
            )
            orgMatchResult.value = listDataUiState
        })
    }

    /** 获取会员预定列表 */
    val allMemberResult: MutableLiveData<ListDataUiState<AllReserveMemberInfoResponse.ListBean>> = MutableLiveData()
    fun getMemberReservationList(isRefresh: Boolean, raceId: Int, name: String, mobile: String, state: Int) {
        if (isRefresh) {
            pageNo = 1
        }
        request({ apiService.getMemberReservationList(pageNo, pageSize, raceId, name, mobile, state) }, {
            pageNo++
            val listDataUiState = ListDataUiState(
                isSuccess = true,
                isRefresh = isRefresh,
                isEmpty = it.isEmpty(),
                isFirstEmpty = isRefresh && it.isEmpty(),
                total = it.total,
                hasMore = it.hasMore(),
                listData = it.list
            )
            allMemberResult.value = listDataUiState
        }, {
            val listDataUiState = ListDataUiState(
                isSuccess = false, isRefresh = isRefresh, errMessage = it.msg, listData = arrayListOf<AllReserveMemberInfoResponse.ListBean>()
            )
            allMemberResult.value = listDataUiState
        })
    }

    /**  消息列表  */
    var messageList: MutableLiveData<ListDataUiState<MessageListResponse.DataList>> = MutableLiveData()
    fun getMessageList(isRefresh: Boolean, msgType: String, lockOrgId: String) {
        if (isRefresh) {
            pageNo = 1
        }
        request({ apiService.getMessageList(pageNo, pageSize, "2", "", msgType, lockOrgId) }, {
            pageNo++
            val listDataUiState = ListDataUiState(
                isSuccess = true,
                isRefresh = isRefresh,
                isEmpty = it.isEmpty(),
                isFirstEmpty = isRefresh && it.isEmpty(),
                hasMore = it.hasMore(),
                listData = it.data
            )
            messageList.value = listDataUiState
        }, {
            val listDataUiState =
                ListDataUiState(isSuccess = false, isRefresh = isRefresh, errMessage = it.msg, listData = arrayListOf<MessageListResponse.DataList>())
            messageList.value = listDataUiState
        })
    }

    /** 公告获取组织信息 */
    fun searchOrgById(orgId: Int) {
        request({ apiService.searchOrgById(orgId) }, {
            orgInfoResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 获取团体赛列表 */
    val appTeamListResult: MutableLiveData<AppTeamListResponse> = MutableLiveData()
    fun getAppTeamList(raceId: String) {
        request({ apiService.getAppTeamList(raceId) }, {
            appTeamListResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 获取会员预定详情 */
    val memberReservationResult: MutableLiveData<MemberReservationResponse> = MutableLiveData()
    fun getMemberReservation(raceId: String) {
        request({ apiService.getMemberReservation(raceId) }, {
            memberReservationResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    //    /** 获取赛事信息 */
    val raceInfoResult: MutableLiveData<RaceInfoResponse> = MutableLiveData()
//    fun getRaceInfo(raceId: Int, orgId: Int) {
//        request({ apiService.getRaceInfo(raceId, orgId) }, {
//            raceInfoResult.value = it
//        }, {
//            RxToast.warning(it.msg)
//        })
//    }

    /** 获取公棚详情 */
    val orgInfoDetailResult: MutableLiveData<OrgInfoDetailResponse> = MutableLiveData()
    fun orgInfoToApp(id: String) {
        request({ apiService.orgInfoToApp(id) }, {
            orgInfoDetailResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 删除消息 */
    val deleteMsgResult: MutableLiveData<UiState> = MutableLiveData()
    fun deleteMessage(id: String) {
        request({ apiService.deleteMessage(id) }, {
            //请求成功
            val result = UiState(isSuccess = true)
            deleteMsgResult.value = result
        }, {
            val result = UiState(isSuccess = true, errorMsg = it.msg)
            deleteMsgResult.value = result
        })
    }

    /** 新增会员预定 */
    val addMemberResult: MutableLiveData<UiState> = MutableLiveData()
    fun addMemberReservation(param: AddMemberReservationParam) {
        request({ apiService.addMemberReservation(param) }, {
            val result = UiState(isSuccess = true)
            addMemberResult.value = result
        }, {
            val result = UiState(isSuccess = true, errorMsg = it.msg)
            addMemberResult.value = result
        })
    }

    /** 新增会员预定 */
    fun editMemberReservation(param: AddMemberReservationParam) {
        request({ apiService.editMemberReservation(param) }, {
            val result = UiState(isSuccess = true)
            addMemberResult.value = result
        }, {
            val result = UiState(isSuccess = true, errorMsg = it.msg)
            addMemberResult.value = result
        })
    }

    /** 获取公棚会员详情  */
    val memberDetailResult: MutableLiveData<LoftMemberInfoResponse> = MutableLiveData()
    fun getLoftMemberDetail(id: String) {
        request({ apiService.getLoftMemberDetail(id) }, {
            memberDetailResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 获取探视设置  */
    val getVisitSettingResult: MutableLiveData<VisitSettingResponse> = MutableLiveData()
    fun getVisitSetting(raceId: String) {
        request({ apiService.getVisitSetting(raceId) }, {
            getVisitSettingResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 获取探视预定详情  */
    val visitResult: MutableLiveData<VisitReservationResponse> = MutableLiveData()
    fun getLoftPigeonListByMemberId(raceId: Int, memberId: Int) {
        request({ apiService.getVisitReservationInfo(raceId, memberId) }, {
            visitResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 获取公棚下赛事的预约通道和预约探视的状态 */
    fun getOrgRaceInfoState(raceId: Int, orgId: Int, type: String) {
        viewModelScope.launch {
            try {
                if (type == "org") {
                    val result1 = apiService.getMemberReservation(raceId.toString())
                    memberReservationResult.value = result1.data

                    val result2 = apiService.getVisitMemberNoList(raceId.toString())
                    visitMemberResult.value = result2.data

                    val result3 = apiService.getRaceInfo(0, orgId)
                    raceInfoResult.value = result3.data

                } else {
                    val result1 = apiService.getMemberReservation(raceId.toString())
                    memberReservationResult.value = result1.data

                    val result2 = apiService.getVisitMemberNoList(raceId.toString())
                    visitMemberResult.value = result2.data

                    val result3 = apiService.getRaceInfo(raceId, 0)
                    raceInfoResult.value = result3.data
                }
            } catch (e: Exception) {
                LogUtils.warnInfo("MainViewModel", "Error occurred: ${e.localizedMessage}")
            }
        }
    }

    fun getVisitInfo(raceId: Int, memberId: Int) {
        viewModelScope.launch {
            try {
                val result1 = apiService.getVisitReservationInfo(raceId, memberId)
                visitResult.value = result1.data
                if (result1.isSucces()) {
                    val result2 = apiService.getVisitSetting(raceId.toString())
                    if (result2.isSucces()) {
                        getVisitSettingResult.value = result2.data
                    }
                }
                LogUtils.warnInfo(result1.code.toString())
            } catch (e: Exception) {
                LogUtils.warnInfo("MainViewModel", "Error occurred: ${e.localizedMessage}")
            }
        }
    }

    /** 获取单用户下探视棚号列表  */
    val visitMemberResult: MutableLiveData<VisitMemberListResponse> = MutableLiveData()
    fun getVisitMemberNoList(raceId: String) {
        request({ apiService.getVisitMemberNoList(raceId) }, {
            visitMemberResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 新增探视预定  */
    val addVisitResult: MutableLiveData<Any> = MutableLiveData()
    fun addVisitReservation(body: RequestBody) {
        request({ apiService.addVisitReservation(body) }, {
            addVisitResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 修改探视预定  */
    fun editVisitReservationInfo(body: RequestBody) {
        request({ apiService.editVisitReservationInfo(body) }, {
            addVisitResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 获取预定探视公告  */
    val visitNoticeResult: MutableLiveData<VisitNoticeResponse> = MutableLiveData()
    fun getVisitNotice(raceId: String) {
        request({ apiService.getVisitNotice(raceId) }, {
            visitNoticeResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 收鸽清单 */
    val receiptPigeonResult: MutableLiveData<ListDataUiState<ReceiptPigeonResponse.ListBean>> = MutableLiveData()
    fun getLoftPigeonListByRaceId(isRefresh: Boolean, member: String, ringId: String, raceId: Int) {
        if (isRefresh) {
            pageNo = 1
        }
        request({ apiService.getLoftPigeonListByRaceId(pageNo, pageSize, member, ringId, raceId) }, {
            pageNo++
            val listDataUiState = ListDataUiState(
                isSuccess = true,
                isRefresh = isRefresh,
                isEmpty = it.isEmpty(),
                isFirstEmpty = isRefresh && it.isEmpty(),
                hasMore = it.hasMore(),
                total = it.total,
                listData = it.list
            )
            receiptPigeonResult.value = listDataUiState
        }, {
            val listDataUiState =
                ListDataUiState(
                    isSuccess = false,
                    isRefresh = isRefresh,
                    errMessage = it.msg,
                    listData = arrayListOf<ReceiptPigeonResponse.ListBean>()
                )
            receiptPigeonResult.value = listDataUiState
        })
    }

    /** 获取全部预定探视会员列表 */
    val allVisitInfoResult: MutableLiveData<ListDataUiState<AllVisitInfoResponse.ListBean>> = MutableLiveData()
    fun getVisitList(isRefresh: Boolean, memberName: String, raceId: Int) {
        if (isRefresh) {
            pageNo = 1
        }
        request({ apiService.getVisitList(pageNo, pageSize, memberName, raceId) }, {
            pageNo++
            val listDataUiState = ListDataUiState(
                isSuccess = true,
                isRefresh = isRefresh,
                isEmpty = it.isEmpty(),
                isFirstEmpty = isRefresh && it.isEmpty(),
                hasMore = it.hasMore(),
                total = it.total,
                listData = it.list,
                payState = it.payState
            )
            allVisitInfoResult.value = listDataUiState
        }, {
            val listDataUiState =
                ListDataUiState(
                    isSuccess = false,
                    isRefresh = isRefresh,
                    errMessage = it.msg,
                    listData = arrayListOf<AllVisitInfoResponse.ListBean>()
                )
            allVisitInfoResult.value = listDataUiState
        })
    }

    /** 获取全部预定探视会员列表 */
    val allVisitInfoStateResult: MutableLiveData<AllVisitInfoResponse> = MutableLiveData()
    fun getVisitListState(memberName: String, raceId: Int) {
        request({ apiService.getVisitListState(pageNo, pageSize, memberName, raceId) }, {
            allVisitInfoStateResult.value = it
        }, {
            RxToast.showToast(it.msg)
        })
    }

    /** 上传凭证 */
    val voucherResult: MutableLiveData<UiState> = MutableLiveData()
    fun uploadVoucher(param: VoucherParams, type: String) {

        val voucherFile1 = param.voucher1
        val voucherFile2 = param.voucher2
        val voucherFile3 = param.voucher3

        val fileList = HashMap<String, File?>()
        val hashMap = HashMap<String, String>()
        hashMap["id"] = param.id.toString()
        hashMap["remitter"] = param.remitter

        if (voucherFile1 != null) {
            fileList["voucher1"] = voucherFile1
        } else {
            hashMap["voucher1"] = ""
        }
        if (voucherFile2 != null) {
            fileList["voucher2"] = voucherFile2
        } else {
            hashMap["voucher2"] = ""
        }
        if (voucherFile3 != null) {
            fileList["voucher3"] = voucherFile3
        } else {
            hashMap["voucher3"] = ""
        }
        val body = SettingUtil.filesToMultipartBody(fileList, hashMap)
        if (type == "ActivityMakeAnAppointment") {
            request({ apiService.uploadVoucher(body) }, {
                val result = UiState(isSuccess = true)
                voucherResult.value = result
            }, {
                val result = UiState(isSuccess = false, errorMsg = it.msg)
                voucherResult.value = result
            })
        } else {
            request({ apiService.uploadVisitVoucher(body) }, {
                val result = UiState(isSuccess = true)
                voucherResult.value = result
            }, {
                val result = UiState(isSuccess = false, errorMsg = it.msg)
                voucherResult.value = result
            })
        }
    }

    /** 获取赛鸽寄养列表 */
    var tentPicData: MutableLiveData<ListDataUiState<PigeonFosterBean.ListData>> = MutableLiveData()
    fun getLoftPigeonListByUserWithOrgForOpen(isRefresh: Boolean, mOrgId: String, raceId: String, ringOrMember: String) {
        if (isRefresh) {
            pageNo = 1
        }
        request({ apiService.getLoftPigeonListByUserWithOrgForOpen(pageNo, 20, mOrgId, raceId, ringOrMember) }, {
            pageNo++
            val listDataUiState = ListDataUiState(
                isSuccess = true,
                isRefresh = isRefresh,
                isEmpty = it.isEmpty(),
                isFirstEmpty = isRefresh && it.isEmpty(),
                hasMore = it.hasMore(),
                listData = it.list,
                total = it.total
            )
            tentPicData.value = listDataUiState
        }, {
            val listDataUiState =
                ListDataUiState(isSuccess = false, isRefresh = isRefresh, errMessage = it.msg, listData = arrayListOf<PigeonFosterBean.ListData>())
            tentPicData.value = listDataUiState
        })
    }

    /** 用户获取探视视频 */
    val getVisitVideoResult: MutableLiveData<ListDataUiState<GetVideoListResponse.ListData>> = MutableLiveData()
    fun getMyVisitVideo(isRefresh: Boolean, memberName: String, ringId: String, raceId: Int) {
        if (isRefresh) {
            pageNo = 1
        }
        request({ apiService.getMyVisitVideo(pageNo, pageSize, raceId, memberName, ringId) }, {
            pageNo++
            val listDataUiState = ListDataUiState(
                isSuccess = true,
                isRefresh = isRefresh,
                isEmpty = it.isEmpty(),
                isFirstEmpty = isRefresh && it.isEmpty(),
                hasMore = it.hasMore(),
                total = it.total,
                listData = it.list
            )
            getVisitVideoResult.value = listDataUiState
        }, {
            val listDataUiState =
                ListDataUiState(
                    isSuccess = false,
                    isRefresh = isRefresh,
                    errMessage = it.msg,
                    listData = arrayListOf<GetVideoListResponse.ListData>()
                )
            getVisitVideoResult.value = listDataUiState
        })
    }

    /** 获取羽色列表 */
    var featherColorResult: MutableLiveData<ListDataUiState<FeatherColorResponse.ColorList>> = MutableLiveData()
    fun getFeatherColor() {
        request({ apiService.getFeatherColor() }, {
            val listDataUiState = ListDataUiState(
                isSuccess = true, isEmpty = it.isEmpty(), listData = it.list
            )
            featherColorResult.value = listDataUiState
        }, {
            val listDataUiState = ListDataUiState(isSuccess = false, errMessage = it.msg, listData = arrayListOf<FeatherColorResponse.ColorList>())
            featherColorResult.value = listDataUiState
        })
    }

    /** 获取用户所属公棚下会员列表 */
    var loftMemberResult: MutableLiveData<LoftMemberResponse> = MutableLiveData()
    fun getLoftMemberListByUserIdAndOrgId(orgId: String, raceId: Int) {
        request({ apiService.getLoftMemberListByUserIdAndOrgId(orgId, raceId) }, {
            loftMemberResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 滴滴接鸽-创建订单（会员角色） */
    var addDrippingResult: MutableLiveData<Any> = MutableLiveData()
    fun addOrderDidi(param: AddDrippingParam) {
        request({ apiService.addOrderDidi(param) }, {
            addDrippingResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 查询接鸽员申请中关于个人的信息查询（用户角色）  */
    var drippingBaseInfoResult: MutableLiveData<DrippingBaseInfoResponse> = MutableLiveData()
    fun getTransporterApplyBaseByUserId() {
        request({ apiService.getTransporterApplyBaseByUserId() }, {
            drippingBaseInfoResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

    /** 注销/删除接鸽员资格 */
    var deleteCatcherResult: MutableLiveData<Any> = MutableLiveData()
    fun deleteTransporter(id: String) {
        request({ apiService.deleteTransporterWithOrg(id) }, {
            deleteCatcherResult.value = it
        }, {
            RxToast.warning(it.msg)
        })
    }

}